package Selenium;

import Selenium.Utils.Firefox;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

/**
 * @author wq
 * @since 2022-06-21 15:24
 */

public class Login {

    public String  doLogin(){
        FirefoxDriver firefoxDriver = Firefox.firefoxDriver;
        firefoxDriver.get("http://api-test.995120.cn/dwadmin/");
        WebElement element = firefoxDriver.findElement(By.xpath("/html/body/div[1]/div/div/div[2]/form/div[1]/div/div/input"));
        element.sendKeys("admin");
        WebElement element1 = firefoxDriver.findElement(By.xpath("/html/body/div[1]/div/div/div[2]/form/div[2]/div/div/input"));
        element1.sendKeys("123456");
        WebElement element2 = firefoxDriver.findElement(By.xpath("/html/body/div[1]/div/div/div[2]/form/div[3]/button"));
        element2.click();
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        String text = firefoxDriver.findElement(By.xpath("/html/body/div[2]")).getText();
        firefoxDriver.quit();
        return text;
    }
}
